// 动态加载组件
const DynamicComponentLoader: React.FC<{ config }> = ({ config }) => {
  const [Component, setComponent] = useState<React.ComponentType | null>(null);
  const { componentName } = config;
  useEffect(() => {
    const loadComponent = async () => {
      try {
        const module = await import(
          `@/components/Editor/components/${componentName}/${componentName}.tsx`
        );
        setComponent(() => module.default);
      } catch (err) {
        console.error(`模块加载失败: ${componentName}`, err);
      }
    };
    loadComponent();
  }, [componentName]);

  return Component ? <Component /> : null;
};

export default DynamicComponentLoader;